<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <link type="text/css" rel="stylesheet" href="../style.css" />
    <h:head>
        <title>Main Account Page</title>
    </h:head>
    <h:body>
        <h1> Shopping Cart </h1>
        <h:form id="viewcartForm" styleClass="form">
            <p><br></br></p>
            <p><br></br></p>
            <p>
                <h:link value="go to shop page" outcome="inventory"/>
                <br/>
            </p>
            <p>
                <h:panelGrid id="cartItems" rendered="#{shoppingCartManager.cartNotEmpty}" headerClass="list-header">
                    <f:facet name="header">
                        <h:outputText value="Shopping Cart Items"/>
                    </f:facet>
                    <h:dataTable id="shoppingcartTbl" value="#{shoppingCartManager.shoppingCartItems}" var="cart"
                                 styleClass="cart-table" headerClass="cart-table-header"
                                 rowClasses="cart-table-odd-row,cart-table-even-row" border="1"
                                 footerClass="footer">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Quantity"/>
                            </f:facet>
                            <h:outputText value="#{cart.nbrOfUnits}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Gnome Type" />
                            </f:facet>
                            <h:outputText value="#{cart.gnomeType}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Price"/>
                            </f:facet>
                            <h:outputText value="#{cart.price}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Action"/>
                            </f:facet>
                            <h:commandLink value="Remove Item" action="#{shoppingCartManager.deleteAction(cart)}"/>
                        </h:column>
                        <f:facet name="footer">
                            <h:panelGroup>
                                <h:outputText value="Total Price - "/>
                                <h:outputText value="#{shoppingCartManager.totalPrice}" />
                            </h:panelGroup>
                        </f:facet>
                    </h:dataTable>
                </h:panelGrid>
            </p>
            <p>
                <h:commandButton id="submit" value="Checkout" action="#{shoppingCartManager.checkout}" rendered="#{shoppingCartManager.cartNotEmpty}" />
            </p>
            <p>
                <h:outputText value="No Items in the shopping cart." rendered="#{not shoppingCartManager.cartNotEmpty}" styleClass="error"/>
                <h:message for="submit" errorClass="error" />
            </p>
        </h:form>
    </h:body>
</html>

